﻿'Imports System.Data.SqlClient
Imports System.Net.Mail
Imports System.Threading
Imports BKO.Domain.Model

Module MOD_INF_TECH_LOAD
	Private zID As String

	Public Sub LOADnet(ByVal sID As String)
		On Error Resume Next
		Dim rs As ADODB.Recordset 'Объявляем рекордсет
		Dim sSQL As String 'Переменная, где будет размещён SQL запрос

		Dim comp As IComp = frmMain.compService.Get(sID)

		frmComputers.lblSidNET.Text = comp.ID
		frmComputers.cmbNetDev.Text = comp.PRINTER_NAME_1
		frmComputers.cmbDevNet.Text = comp.PRINTER_SN_1
		frmComputers.PROiZV40.Text = comp.PRINTER_PROIZV_1

		frmComputers.txtNetIP.Text = comp.PRINTER_NAME_2
		frmComputers.txtNetMac.Text = comp.PRINTER_PROIZV_2
		frmComputers.txtNetPort.Text = comp.PRINTER_SN_2

		frmComputers.txtNetINN.Text = comp.PRINTER_PROIZV_3
		frmComputers.txtNetIsp.Text = comp.PRINTER_SN_3

		frmComputers.cmbNetVkl.Text = comp.PRINTER_NAME_4
		frmComputers.cmbNetCable.Text = comp.PRINTER_PROIZV_4
		frmComputers.txtNetCableCat.Text = comp.PRINTER_SN_4

		frmComputers.cmbNETotv.Text = comp.OTvetstvennyj
		frmComputers.txtNETphone.Text = comp.TELEPHONE
		frmComputers.txtNetNumberPorts.Text = comp.PORT_2

		frmComputers.cmbNETBranch.Text = comp.FILIAL
		frmComputers.cmbNetDepart.Text = comp.MESTO
		frmComputers.cmbNETOffice.Text = comp.kabn

		frmComputers.txtNETSfN.Text = comp.SFAktNo
		frmComputers.txtNETcash.Text = comp.CenaRub
		frmComputers.txtNETSumm.Text = comp.StoimRub
		frmComputers.txtNETZay.Text = comp.Zaiavk

		frmComputers.dtNETdataVvoda.Value = comp.DataVVoda
		frmComputers.dtNETSFdate.Value = comp.dataSF

		frmComputers.chkNETspis.Checked = comp.Spisan
		frmComputers.chkNETNNb.Checked = comp.Balans

		sName = frmComputers.cmbDevNet.Text

		frmComputers.txtNetSN.Text = comp.PORT_1

		If comp.PCL.HasValue Then
			Dim comp1 As IComp = frmMain.compService.Get(comp.PCL.Value)
			frmComputers.cmbCNTNet.Text = comp1.NET_NAME
			comp1 = Nothing
		End If

		'#############################################
		'Проверка есть ли контейнеры в справочнике
		'#############################################

		sSQL = "SELECT count(*) as t_n from spr_other where C='1'"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		Dim A1 As String
		With rs
			A1 = .Fields("t_n").Value
		End With
		rs.Close()
		rs = Nothing

		Select Case A1
			Case 0
				frmComputers.cmbCNTNet.Visible = False
				frmComputers.lblPCLNET.Visible = False
			Case Else
				frmComputers.cmbCNTNet.Visible = True
				frmComputers.lblPCLNET.Visible = True

				Call LOAD_PCL(frmComputers.cmbNETBranch.Text, frmComputers.cmbNetDepart.Text, frmComputers.cmbNETOffice.Text, frmComputers.cmbCNTNet)
				'Call LOAD_PCL(frmComputers.cmbBranch.Text, frmComputers.cmbDepartment.Text, frmComputers.cmbOffice.Text, frmComputers.cmbPCLK)
		End Select

		'#############################################
		'#############################################
		'#############################################

		Call LOAD_GARs(sID, frmComputers.cmbNETPostav, frmComputers.dtGNETPr, frmComputers.dtGNETok)
		' Call LOAD_NET_PORT(sID)
		Call LOAD_NET_PORT2(sID)
		Call LOAD_NOTES(sID, frmComputers.lvNotesNET)
		Call LOAD_REPAIR(sID, frmComputers.lvRepairNET)
		Call LOAD_DVIG_TEHN(sID, frmComputers.lvMovementNET)
	End Sub

	Public Sub LOAD_NET_PORT(ByVal sID As String)
		Dim rs1 As ADODB.Recordset
		rs1 = New ADODB.Recordset
		rs1.Open("SELECT count(*) as t_n FROM net_port WHERE id_net=" & sID, DB7, ADODB.CursorTypeEnum.adOpenKeyset)

		frmComputers.lvNetPort.Sorting = SortOrder.None
		frmComputers.lvNetPort.ListViewItemSorter = Nothing
		frmComputers.lvNetPort.Items.Clear()

		Dim UCount As Integer

		With rs1
			UCount = .Fields("t_n").Value
		End With
		rs1.Close()
		rs1 = Nothing

		If UCount > 0 Then
			rs1 = New ADODB.Recordset
			rs1.Open("SELECT * FROM net_port WHERE id_net=" & sID, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			Dim intCount As Decimal = 0

			With rs1
				.MoveFirst()
				Do While Not .EOF
					frmComputers.lvNetPort.Items.Add(.Fields("id").Value) 'col no. 1

					If Not IsDBNull(.Fields("port").Value) Then
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add(.Fields("port").Value)
					Else
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("net_n").Value) Then
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add(.Fields("net_n").Value)
					Else
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("mac").Value) Then
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add(.Fields("mac").Value)
					Else
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add("")
					End If

					intCount = intCount + 1

					.MoveNext()
				Loop
			End With
			rs1.Close()
			rs1 = Nothing
		End If

		ResList(frmComputers.lvNetPort)
	End Sub

	Public Sub LOAD_NET_PORT2(ByVal sID As Integer)
		On Error GoTo err_

		Dim rs1 As ADODB.Recordset
		rs1 = New ADODB.Recordset
		rs1.Open("SELECT count(*) as t_n FROM TBL_NET_MAG WHERE COMMUTATOR=" & sID, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		frmComputers.lvNetPort.Sorting = SortOrder.None
		frmComputers.lvNetPort.ListViewItemSorter = Nothing
		frmComputers.lvNetPort.Items.Clear()

		Dim UCount As Integer

		With rs1
			UCount = .Fields("t_n").Value
		End With
		rs1.Close()
		rs1 = Nothing

		If UCount > 0 Then
			frmComputers.Label35.Visible = False
			frmComputers.Label34.Visible = False
			frmComputers.Label33.Visible = False
			frmComputers.txtNetnumberPort.Visible = False
			frmComputers.txtNetPortMapping.Visible = False
			frmComputers.txtNetPortMac.Visible = False
			frmComputers.btnNetPortAdd.Visible = False

			rs1 = New ADODB.Recordset
			rs1.Open("SELECT * FROM TBL_NET_MAG WHERE COMMUTATOR=" & sID, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			Dim intCount As Decimal = 0

			With rs1
				.MoveFirst()
				Do While Not .EOF
					frmComputers.lvNetPort.Items.Add(.Fields("id").Value) 'col no. 1

					If Not IsDBNull(.Fields("NET_PORT_COMMUTATOR").Value) Then
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add(.Fields("NET_PORT_COMMUTATOR").Value)
					Else
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add("")
					End If

					Dim comp As IComp = frmMain.compService.Get(.Fields("SVT").Value)

					If Not IsNothing(comp) Then
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add(comp.NET_NAME)
						frmComputers.lvNetPort.Items(CInt(intCount)).SubItems.Add(comp.NET_MAC_1)
					End If

					intCount = intCount + 1

					.MoveNext()
				Loop
			End With
			rs1.Close()
			rs1 = Nothing
		Else
			frmComputers.Label35.Visible = True
			frmComputers.Label34.Visible = True
			frmComputers.Label33.Visible = True
			frmComputers.txtNetnumberPort.Visible = True
			frmComputers.txtNetPortMapping.Visible = True
			frmComputers.txtNetPortMac.Visible = True
			frmComputers.btnNetPortAdd.Visible = True

			LOAD_NET_PORT(sID)
		End If

		ResList(frmComputers.lvNetPort)

		Exit Sub
err_:
		MsgBox(Err.Description)
	End Sub

	Public Sub LOADot(ByVal sID As String)
		On Error Resume Next

		Dim comp As IComp = frmMain.compService.Get(sID)

		frmComputers.lblsIDOTH.Text = comp.ID

		frmComputers.cmbOTH.Text = comp.PRINTER_NAME_1
		frmComputers.txtOTHSN.Text = comp.PRINTER_SN_1
		frmComputers.PROiZV39.Text = comp.PRINTER_PROIZV_1
		frmComputers.txtOTHmemo.Text = comp.PORT_1

		frmComputers.cmbOTHotv.Text = comp.OTvetstvennyj
		frmComputers.txtOTHinnumber.Text = comp.INV_NO_PRINTER

		frmComputers.cmbOTHFil.Text = comp.FILIAL
		frmComputers.cmbOTHDepart.Text = comp.MESTO
		frmComputers.cmbOTHOffice.Text = comp.kabn

		sName = comp.PRINTER_NAME_1

		frmComputers.txtOTHIP.Text = comp.NET_IP_1
		frmComputers.txtOTHMAC.Text = comp.NET_MAC_1
		frmComputers.cmbOTHConnect.Text = comp.TIP_COMPA
		frmComputers.txtOTHphone.Text = comp.TELEPHONE

		frmComputers.txtOTHSfN.Text = comp.SFAktNo
		frmComputers.txtOTHcash.Text = comp.CenaRub
		frmComputers.txtOTHSumm.Text = comp.StoimRub
		frmComputers.txtOTHZay.Text = comp.Zaiavk

		frmComputers.dtOTHdataVvoda.Value = comp.DataVVoda
		frmComputers.dtOTHSFdate.Value = comp.dataSF

		frmComputers.chkOTHspis.Checked = comp.Spisan
		frmComputers.chkOTHNNb.Checked = comp.Balans

		If comp.PCL.HasValue Then
			Dim comp1 As IComp = frmMain.compService.Get(comp.PCL.Value)
			frmComputers.cmbOTHPCL.Text = comp1.NET_NAME
			comp1 = Nothing
		End If

		Call LOAD_GARs(sID, frmComputers.cmbOTHPostav, frmComputers.dtGOTHPr, frmComputers.dtGOTHok)
		'Call LOAD_NOTES(sID, frmComputers.lvNotesOTH)
		'Call LOAD_REPAIR(sID, frmComputers.lvRepairOTH)
		'Call LOAD_DVIG_TEHN(sID, frmComputers.lvMovementOTH)
	End Sub

	Public Sub LOADp(ByVal sID As String)
		On Error Resume Next

		Dim kol As Long
		Dim uname As String
		Dim rs1 As ADODB.Recordset 'Объявляем рекордсет
		Dim sSQL1 As String	'Переменная, где будет размещён SQL запрос

		Dim comp As IComp = frmMain.compService.Get(sID)

		frmComputers.lblSidPRN.Text = comp.ID
		frmComputers.cmbPRN.Text = comp.PRINTER_NAME_1
		frmComputers.cmbModCartr.Text = comp.OS

		If Len(frmComputers.cmbModCartr.Text) <> 0 Then
			Call frmComputers.Tip_Model_CARTR()
		End If

		frmComputers.txtPRNSN.Text = comp.PRINTER_SN_1
		frmComputers.PROiZV38.Text = comp.PRINTER_PROIZV_1
		frmComputers.txtPRNinnumber.Text = comp.INV_NO_PRINTER
		frmComputers.cmbFormat.Text = comp.PORT_1

		frmComputers.cmbPRNFil.Text = comp.FILIAL
		frmComputers.cmbPRNDepart.Text = comp.MESTO
		frmComputers.cmbPRNOffice.Text = comp.kabn

		frmComputers.cmbPRNotv.Text = comp.OTvetstvennyj
		frmComputers.txtPRNphone.Text = comp.TELEPHONE
		frmComputers.txtPrnIP.Text = comp.NET_IP_1
		frmComputers.txtPRNMAC.Text = comp.NET_MAC_1

		frmComputers.txtPRNSfN.Text = comp.SFAktNo
		frmComputers.txtPRNcash.Text = comp.CenaRub
		frmComputers.txtPRNSumm.Text = comp.StoimRub
		frmComputers.txtPRNZay.Text = comp.Zaiavk

		frmComputers.dtPRNdataVvoda.Value = comp.DataVVoda
		frmComputers.dtPRNSFdate.Value = comp.dataSF

		frmComputers.chkPRNspis.Checked = comp.Spisan
		frmComputers.chkPRNNNb.Checked = comp.Balans

		frmComputers.cmbPRNConnect.Text = comp.PORT_2

		sName = comp.PRINTER_NAME_1
			'txtPrnIP

		If Len(frmComputers.cmbModCartr.Text) > 0 Then
			Dim sSQL As String 'Переменная, где будет размещён SQL запрос
			sSQL1 = "SELECT * FROM spr_cart WHERE name='" & frmComputers.cmbTIPCartridg.Text & "'"
			rs1 = New ADODB.Recordset
			rs1.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs1
				frmComputers.cmbTIPCartridg.Text = .Fields("A").Value
			End With
			rs1.Close()
			rs1 = Nothing
		End If

		If comp.PCL.HasValue Then
			Dim comp1 As IComp = frmMain.compService.Get(comp.PCL.Value)
			frmComputers.cmbPCL.Text = comp1.NET_NAME
			comp1 = Nothing
		End If

		Call LOAD_CRT(sID)

		Call LOAD_GARs(sID, frmComputers.cmbPRNPostav, frmComputers.dtGPRNPr, frmComputers.dtGPRNok)

		'Call LOAD_NOTES(sID, frmComputers.lvNotesPRN)
		'Call LOAD_REPAIR(sID, frmComputers.lvRepairPRN)
		'Call LOAD_DVIG_TEHN(sID, frmComputers.lvMovementPRN)
	End Sub

	Public Sub LOAD_CRT(ByVal sID As String)
		On Error Resume Next
		'Обнаруженные картриджи
		frmComputers.lvPRNCartr.Items.Clear()
		frmComputers.lblPRNPage.Text = ""

		Dim kol As Long
		Dim uname As String
		Dim rs1 As ADODB.Recordset
		Dim sSQL1 As String

		sSQL1 = "SELECT COUNT(*) AS t_number FROM CARTRIDG WHERE USTR=" & sID
		rs1 = New ADODB.Recordset
		rs1.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs1
			kol = .Fields("t_number").Value
		End With
		rs1.Close()
		rs1 = Nothing

		If kol <> 0 Then
			Dim intCount As Decimal = 0
			Dim scid As Integer

			'Dim rs1 As ADODB.Recordset 'Объявляем рекордсет
			'Dim sSQL1 As String 'Переменная, где будет размещён SQL запрос

			sSQL1 = "SELECT * FROM CARTRIDG WHERE USTR=" & sID
			rs1 = New ADODB.Recordset
			rs1.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs1
				.MoveFirst()
				Do While Not .EOF
					frmComputers.lvPRNCartr.Items.Add(.Fields("id").Value) 'col no. 1
					uname = .Fields("Model").Value
					scid = .Fields("id").Value

					Dim rs2 As ADODB.Recordset 'Объявляем рекордсет
					Dim sSQL2 As String	'Переменная, где будет размещён SQL запрос

					sSQL2 = "SELECT * FROM spr_cart where ID =" & uname
					rs2 = New ADODB.Recordset
					rs2.Open(sSQL2, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

					With rs2
						If Not IsDBNull(.Fields("name").Value) Then frmComputers.lvPRNCartr.Items(CInt(intCount)).SubItems.Add(.Fields("name").Value)
					End With
					rs2.Close()
					rs2 = Nothing

					If Not IsDBNull(.Fields("SN")) Then frmComputers.lvPRNCartr.Items(CInt(intCount)).SubItems.Add(.Fields("SN").Value)

					Dim uname1 As Decimal = 0
					Dim uname2 As Decimal = 0

					sSQL2 = "SELECT Paper, STOIM FROM CARTRIDG_Z where ID_C =" & scid
					rs2 = New ADODB.Recordset
					rs2.Open(sSQL2, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

					With rs2
						.MoveFirst()
						Do While Not .EOF
							uname1 = uname1 + .Fields("Paper").Value
							uname2 = uname2 + .Fields("STOIM").Value

							.MoveNext()
						Loop
					End With
					rs2.Close()
					rs2 = Nothing

					frmComputers.lblPRNPage.Text = uname1

					sSQL2 = "SELECT COUNT(*) as total_num FROM CARTRIDG_Z where ID_C =" & scid
					rs2 = New ADODB.Recordset
					rs2.Open(sSQL2, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

					With rs2
						If Not IsDBNull(.Fields("total_num").Value) Then frmComputers.lvPRNCartr.Items(CInt(intCount)).SubItems.Add(.Fields("total_num").Value)
					End With
					rs2.Close()
					rs2 = Nothing

					frmComputers.lvPRNCartr.Items(CInt(intCount)).SubItems.Add(uname2)

					intCount = intCount + 1

					.MoveNext()
				Loop
			End With
		End If

		ResList(frmComputers.lvPRNCartr)
	End Sub

	Public Sub LOADt(ByVal sID As String)
		On Error Resume Next
		zID = sID

		Dim comp As IComp = frmMain.compService.Get(sID)

		frmComputers.bCPUPlus.Visible = True
		frmComputers.bRamPlus.Visible = True
		frmComputers.bHddPlus.Visible = True
		frmComputers.bSVGAPlus.Visible = True
		frmComputers.bOpticalPlus.Visible = True
		frmComputers.bNETPlus.Visible = True
		frmComputers.bMonitorPlus.Visible = True
		frmComputers.bPrinterPlus.Visible = True

		'Процессоры
		frmComputers.lblsID.Text = comp.ID

		frmComputers.cmbCPU1.Text = comp.CPU1
		frmComputers.txtMHZ1.Text = comp.CPUmhz1
		frmComputers.txtSoc1.Text = comp.CPUSocket1
		frmComputers.PROizV1.Text = comp.CPUProizv1
		frmComputers.sCPU = 1

		If Not String.IsNullOrEmpty(comp.CPU2) Then
			frmComputers.sCPU = 2
			frmComputers.cmbCPU2.Visible = True
			frmComputers.txtMHZ2.Visible = True
			frmComputers.txtSoc2.Visible = True
			frmComputers.PROizV2.Visible = True

			frmComputers.cmbCPU2.Text = comp.CPU2
			frmComputers.txtMHZ2.Text = comp.CPUmhz2
			frmComputers.txtSoc2.Text = comp.CPUSocket2
			frmComputers.PROizV2.Text = comp.CPUProizv2
		Else
			frmComputers.cmbCPU2.Visible = False
			frmComputers.txtMHZ2.Visible = False
			frmComputers.txtSoc2.Visible = False
			frmComputers.PROizV2.Visible = False
		End If

		If Not String.IsNullOrEmpty(comp.CPU3) Then
			frmComputers.sCPU = 3
			frmComputers.cmbCPU3.Visible = True
			frmComputers.txtMHZ3.Visible = True
			frmComputers.txtSoc3.Visible = True
			frmComputers.PROizV3.Visible = True

			frmComputers.cmbCPU3.Text = comp.CPU3
			frmComputers.txtMHZ3.Text = comp.CPUmhz3
			frmComputers.txtSoc3.Text = comp.CPUSocket3
			frmComputers.PROizV3.Text = comp.CPUProizv3
		Else
			frmComputers.cmbCPU3.Visible = False
			frmComputers.txtMHZ3.Visible = False
			frmComputers.txtSoc3.Visible = False
			frmComputers.PROizV3.Visible = False
		End If

		If Not String.IsNullOrEmpty(comp.CPU4) Then
			frmComputers.sCPU = 4
			frmComputers.bCPUPlus.Visible = False
			frmComputers.cmbCPU4.Visible = True
			frmComputers.txtMHZ4.Visible = True
			frmComputers.txtSoc4.Visible = True
			frmComputers.PROizV4.Visible = True

			frmComputers.cmbCPU2.Text = comp.CPU4
			frmComputers.txtMHZ4.Text = comp.CPUmhz4
			frmComputers.txtSoc4.Text = comp.CPUSocket4
			frmComputers.PROizV4.Text = comp.CPUProizv4
		Else
			frmComputers.cmbCPU4.Visible = False
			frmComputers.txtMHZ4.Visible = False
			frmComputers.txtSoc4.Visible = False
			frmComputers.PROizV4.Visible = False
		End If

		'Материнская плата
		frmComputers.cmbMB.Text = comp.Mb
		frmComputers.txtChip.Text = comp.Mb_Chip
		frmComputers.PROizV5.Text = comp.Mb_Proizvod
		frmComputers.txtSN_MB.Text = comp.Mb_Id

		'Модули памяти
		frmComputers.cmbRAM1.Text = comp.RAM_1
		frmComputers.txtRamSN1.Text = comp.RAM_SN_1
		frmComputers.txtRamS1.Text = comp.RAM_speed_1
		frmComputers.PROizV6.Text = comp.RAM_PROIZV_1
		frmComputers.sRAM = 1

		If Not String.IsNullOrEmpty(comp.RAM_2) Then
			frmComputers.sRAM = frmComputers.sRAM + 1
			frmComputers.cmbRAM2.Visible = True
			frmComputers.txtRamSN2.Visible = True
			frmComputers.txtRamS2.Visible = True
			frmComputers.PROizV7.Visible = True

			frmComputers.cmbRAM2.Text = comp.RAM_2
			frmComputers.txtRamSN2.Text = comp.RAM_SN_2
			frmComputers.txtRamS2.Text = comp.RAM_speed_2
			frmComputers.PROizV7.Text = comp.RAM_PROIZV_2
		Else
			frmComputers.cmbRAM2.Visible = False
			frmComputers.txtRamSN2.Visible = False
			frmComputers.txtRamS2.Visible = False
			frmComputers.PROizV7.Visible = False

		End If

		If Not String.IsNullOrEmpty(comp.RAM_3) Then
			frmComputers.sRAM = frmComputers.sRAM + 1
			frmComputers.cmbRAM2.Visible = True
			frmComputers.txtRamSN2.Visible = True
			frmComputers.txtRamS2.Visible = True
			frmComputers.PROizV7.Visible = True
			frmComputers.cmbRAM3.Visible = True
			frmComputers.txtRamSN3.Visible = True
			frmComputers.txtRamS3.Visible = True
			frmComputers.PROizV8.Visible = True

			frmComputers.cmbRAM3.Text = comp.RAM_3
			frmComputers.txtRamSN3.Text = comp.RAM_SN_3
			frmComputers.txtRamS3.Text = comp.RAM_speed_3
			frmComputers.PROizV8.Text = comp.RAM_PROIZV_3
		Else
			frmComputers.cmbRAM3.Visible = False
			frmComputers.txtRamSN3.Visible = False
			frmComputers.txtRamS3.Visible = False
			frmComputers.PROizV8.Visible = False

		End If

		If Not String.IsNullOrEmpty(comp.RAM_4) Then
			frmComputers.sRAM = frmComputers.sRAM + 1
			frmComputers.bRamPlus.Visible = False
			frmComputers.cmbRAM2.Visible = True
			frmComputers.txtRamSN2.Visible = True
			frmComputers.txtRamS2.Visible = True
			frmComputers.PROizV7.Visible = True
			frmComputers.cmbRAM3.Visible = True
			frmComputers.txtRamSN3.Visible = True
			frmComputers.txtRamS3.Visible = True
			frmComputers.PROizV8.Visible = True
			frmComputers.cmbRAM4.Visible = True
			frmComputers.txtRamSN4.Visible = True
			frmComputers.txtRamS4.Visible = True
			frmComputers.PROizV9.Visible = True

			frmComputers.cmbRAM4.Text = comp.RAM_4
			frmComputers.txtRamSN4.Text = comp.RAM_SN_4
			frmComputers.txtRamSN4.Text = comp.RAM_speed_4
			frmComputers.PROizV9.Text = comp.RAM_PROIZV_4
		Else
			frmComputers.cmbRAM4.Visible = False
			frmComputers.txtRamSN4.Visible = False
			frmComputers.txtRamS4.Visible = False
			frmComputers.PROizV9.Visible = False

		End If

		'Жесткие диски
		frmComputers.cmbHDD1.Text = comp.HDD_Name_1
		frmComputers.txtHDDo1.Text = comp.HDD_OB_1
		frmComputers.txtHDDsN1.Text = comp.HDD_SN_1
		frmComputers.PROizV10.Text = comp.HDD_PROIZV_1
		frmComputers.sHDD = 1

		If Not String.IsNullOrEmpty(comp.HDD_Name_2) Then
			frmComputers.sHDD = 2
			frmComputers.cmbHDD2.Visible = True
			frmComputers.txtHDDo2.Visible = True
			frmComputers.txtHDDsN2.Visible = True
			frmComputers.PROizV11.Visible = True

			frmComputers.cmbHDD2.Text = comp.HDD_Name_2
			frmComputers.txtHDDo2.Text = comp.HDD_OB_2
			frmComputers.txtHDDsN2.Text = comp.HDD_SN_2
			frmComputers.PROizV11.Text = comp.HDD_PROIZV_2
		Else
			frmComputers.cmbHDD2.Visible = False
			frmComputers.txtHDDo2.Visible = False
			frmComputers.txtHDDsN2.Visible = False
			frmComputers.PROizV11.Visible = False
		End If

		If Not String.IsNullOrEmpty(comp.HDD_Name_3) Then
			frmComputers.sHDD = 3
			frmComputers.cmbHDD3.Visible = True
			frmComputers.txtHDDo3.Visible = True
			frmComputers.txtHDDsN3.Visible = True
			frmComputers.PROizV12.Visible = True

			frmComputers.cmbHDD3.Text = comp.HDD_Name_3
			frmComputers.txtHDDo3.Text = comp.HDD_OB_3
			frmComputers.txtHDDsN3.Text = comp.HDD_SN_3
			frmComputers.PROizV12.Text = comp.HDD_PROIZV_3
		Else
			frmComputers.cmbHDD3.Visible = False
			frmComputers.txtHDDo3.Visible = False
			frmComputers.txtHDDsN3.Visible = False
			frmComputers.PROizV12.Visible = False
		End If

		If Not String.IsNullOrEmpty(comp.HDD_Name_4) Then
			frmComputers.sHDD = 4
			frmComputers.bHddPlus.Visible = False
			frmComputers.cmbHDD4.Visible = True
			frmComputers.txtHDDo4.Visible = True
			frmComputers.txtHDDsN4.Visible = True
			frmComputers.PROizV13.Visible = True

			frmComputers.cmbHDD4.Text = comp.HDD_Name_4
			frmComputers.txtHDDo4.Text = comp.HDD_OB_4
			frmComputers.txtHDDsN4.Text = comp.HDD_SN_4
			frmComputers.PROizV13.Text = comp.HDD_PROIZV_4
		Else
			frmComputers.cmbHDD4.Visible = False
			frmComputers.txtHDDo4.Visible = False
			frmComputers.txtHDDsN4.Visible = False
			frmComputers.PROizV13.Visible = False
		End If

		'Видео карта
		frmComputers.cmbSVGA1.Text = comp.SVGA_NAME
		frmComputers.txtSVGAr1.Text = comp.SVGA_OB_RAM
		frmComputers.txtSVGAs1.Text = comp.SVGA_SN
		frmComputers.PROizV14.Text = comp.SVGA_PROIZV
		frmComputers.sVGA = 1

		If Not String.IsNullOrEmpty(comp.SVGA2_NAME) Then
			frmComputers.sVGA = 2
			frmComputers.bSVGAPlus.Visible = False
			frmComputers.cmbSVGA2.Visible = True
			frmComputers.txtSVGAs2.Visible = True
			frmComputers.txtSVGAr2.Visible = True
			frmComputers.PROizV15.Visible = True

			frmComputers.cmbSVGA2.Text = comp.SVGA2_NAME
			frmComputers.txtSVGAr2.Text = comp.SVGA2_OB_RAM
			frmComputers.txtSVGAs2.Text = comp.SVGA2_SN
			frmComputers.PROizV15.Text = comp.SVGA2_PROIZV
		Else
			frmComputers.cmbSVGA2.Visible = False
			frmComputers.txtSVGAr2.Visible = False
			frmComputers.txtSVGAs2.Visible = False
			frmComputers.PROizV15.Visible = False
		End If

		'Звуковая карта
		frmComputers.cmbSound.Text = comp.SOUND_NAME
		frmComputers.txtSoundS.Text = comp.SOUND_SN
		frmComputers.PROizV16.Text = comp.SOUND_PROIZV

		'Оптические накопители
		frmComputers.cmbOPTIC1.Text = comp.CD_NAME
		frmComputers.txtOPTICs1.Text = comp.CD_SPEED
		frmComputers.txtOPTICsn1.Text = comp.CD_SN
		frmComputers.PROizV17.Text = comp.CD_PROIZV
		frmComputers.sOPTICAL = 1

		If Not String.IsNullOrEmpty(comp.CDRW_NAME) Then
			frmComputers.sOPTICAL = 2
			frmComputers.cmbOPTIC2.Visible = True
			frmComputers.txtOPTICs2.Visible = True
			frmComputers.txtOPTICsn2.Visible = True
			frmComputers.PROizV18.Visible = True

			frmComputers.cmbOPTIC2.Text = comp.CDRW_NAME
			frmComputers.txtOPTICs2.Text = comp.CDRW_SPEED
			frmComputers.txtOPTICsn2.Text = comp.CDRW_SN
			frmComputers.PROizV18.Text = comp.CDRW_PROIZV
		Else
			frmComputers.cmbOPTIC2.Visible = False
			frmComputers.txtOPTICs2.Visible = False
			frmComputers.txtOPTICsn2.Visible = False
			frmComputers.PROizV18.Visible = False
		End If

		If Not String.IsNullOrEmpty(comp.DVD_NAME) Then
			frmComputers.sOPTICAL = 3
			frmComputers.bOpticalPlus.Visible = False
			frmComputers.cmbOPTIC3.Visible = True
			frmComputers.txtOPTICs3.Visible = True
			frmComputers.txtOPTICsn3.Visible = True
			frmComputers.PROizV19.Visible = True

			frmComputers.cmbOPTIC3.Text = comp.DVD_NAME
			frmComputers.txtOPTICs3.Text = comp.DVD_SPEED
			frmComputers.txtOPTICsn3.Text = comp.DVD_SN
			frmComputers.PROizV19.Text = comp.DVD_PROIZV
		Else
			frmComputers.cmbOPTIC3.Visible = False
			frmComputers.txtOPTICs3.Visible = False
			frmComputers.txtOPTICsn3.Visible = False
			frmComputers.PROizV19.Visible = False
		End If

		'Сетевые карты
		frmComputers.cmbNET1.Text = comp.NET_NAME_1
		frmComputers.txtNETip1.Text = comp.NET_IP_1
		frmComputers.txtNETmac1.Text = comp.NET_MAC_1
		frmComputers.PROizV20.Text = comp.NET_PROIZV_1
		frmComputers.sNET = 1

		If Not String.IsNullOrEmpty(comp.NET_NAME_2) Then
			frmComputers.sNET = 2
			frmComputers.bNETPlus.Visible = False
			frmComputers.cmbNET2.Visible = True
			frmComputers.txtNETip2.Visible = True
			frmComputers.txtNETmac2.Visible = True
			frmComputers.PROizV21.Visible = True

			frmComputers.cmbNET2.Text = comp.NET_NAME_2
			frmComputers.txtNETip2.Text = comp.NET_IP_2
			frmComputers.txtNETmac2.Text = comp.NET_MAC_2
			frmComputers.PROizV21.Text = comp.NET_PROIZV_2
		Else
			frmComputers.cmbNET2.Visible = False
			frmComputers.txtNETip2.Visible = False
			frmComputers.txtNETmac2.Visible = False
			frmComputers.PROizV21.Visible = False
		End If

		'Дисковод
		frmComputers.cmbFDD.Text = comp.FDD_NAME
		frmComputers.txtSN.Text = comp.FDD_SN
		frmComputers.PROizV22.Text = comp.FDD_PROIZV

		'Кардридер
		frmComputers.cmbCreader.Text = comp.CREADER_NAME
		frmComputers.txtCreader1.Text = comp.CREADER_SN
		frmComputers.PROizV23.Text = comp.CREADER_PROIZV

		'Модем
		frmComputers.cmbModem.Text = comp.MODEM_NAME
		frmComputers.txtModemSN.Text = comp.MODEM_SN
		frmComputers.PROizV24.Text = comp.MODEM_PROIZV

		'Корпус
		frmComputers.cmbCase.Text = comp.CASE_NAME
		frmComputers.txtCase1.Text = comp.CASE_SN
		frmComputers.PROizV25.Text = comp.CASE_PROIZV

		'Блок питания
		frmComputers.cmbBP.Text = comp.BLOCK
		frmComputers.txtBP1.Text = comp.SN_BLOCK
		frmComputers.PROizV26.Text = comp.PROIZV_BLOCK

		'Производитель системного блока
		frmComputers.PROizV27.Text = comp.SYS_PR

		'Серийный номер системного блока
		frmComputers.txtSNSB.Text = comp.Ser_N_SIS

		'Модель системного блока
		frmComputers.txtModSB.Text = comp.PATH

		'USB
		frmComputers.cmbUSB.Text = comp.USB_NAME
		frmComputers.txtUSBSN.Text = comp.USB_SN
		frmComputers.PROizV41.Text = comp.USB_PROIZV

		'PCI
		frmComputers.cmbPCI.Text = comp.PCI_NAME
		frmComputers.txtSNPCI.Text = comp.PCI_SN
		frmComputers.PROizV42.Text = comp.PCI_PROIZV

		'Монитор
		'1
		frmComputers.cmbMon1.Text = comp.MONITOR_NAME
		frmComputers.txtMon1Dum.Text = comp.MONITOR_DUM
		frmComputers.txtMon1SN.Text = comp.MONITOR_SN
		frmComputers.PROizV28.Text = comp.MONITOR_PROIZV

		'2
		frmComputers.sMonitor = 1
		If Not String.IsNullOrEmpty(comp.MONITOR_NAME2) Then
			frmComputers.sMonitor = 2
			frmComputers.bMonitorPlus.Visible = False
			frmComputers.cmbMon2.Visible = True
			frmComputers.txtMon2Dum.Visible = True
			frmComputers.txtMon2SN.Visible = True
			frmComputers.PROizV29.Visible = True

			frmComputers.cmbMon2.Text = comp.MONITOR_NAME2
			frmComputers.txtMon2Dum.Text = comp.MONITOR_DUM2
			frmComputers.txtMon2SN.Text = comp.MONITOR_SN2
			frmComputers.PROizV29.Text = comp.MONITOR_PROIZV2
		Else
			frmComputers.cmbMon2.Visible = False
			frmComputers.txtMon2Dum.Visible = False
			frmComputers.txtMon2SN.Visible = False
			frmComputers.PROizV29.Visible = False
		End If

		'Клавиатура
		frmComputers.cmbKeyb.Text = comp.KEYBOARD_NAME
		frmComputers.txtKeybSN.Text = comp.KEYBOARD_SN
		frmComputers.PROizV30.Text = comp.KEYBOARD_PROIZV

		'Мышь
		frmComputers.cmbMouse.Text = comp.MOUSE_NAME
		frmComputers.txtMouseSN.Text = comp.MOUSE_SN
		frmComputers.PROizV31.Text = comp.MOUSE_PROIZV

		'Колонки
		frmComputers.cmbAsist.Text = comp.AS_NAME
		frmComputers.txtAsistSN.Text = comp.AS_SN
		frmComputers.PROizV32.Text = comp.AS_PROIZV

		'Сетевой фильтр
		frmComputers.cmbFilter.Text = comp.FILTR_NAME
		frmComputers.txtFilterSN.Text = comp.FILTR_SN
		frmComputers.PROizV33.Text = comp.FILTR_PROIZV

		'ИБП
		frmComputers.cmbIBP.Text = comp.IBP_NAME
		frmComputers.txtSNIBP.Text = comp.IBP_SN
		frmComputers.PROizV43.Text = comp.IBP_PROIZV

		'Подключенные принтеры
		frmComputers.cmbPrinters1.Text = comp.PRINTER_NAME_1
		frmComputers.txtPrint1SN.Text = comp.PRINTER_SN_1
		frmComputers.txtPrint1Port.Text = comp.PORT_1
		frmComputers.PROizV34.Text = comp.PRINTER_PROIZV_1
		frmComputers.sPrinter = 1

		If Not String.IsNullOrEmpty(comp.PRINTER_NAME_2) Then
			frmComputers.sPrinter = 2
			frmComputers.cmbPrinters2.Visible = True
			frmComputers.txtPrint2SN.Visible = True
			frmComputers.txtPrint2Port.Visible = True
			frmComputers.PROizV35.Visible = True

			frmComputers.cmbPrinters2.Text = comp.PRINTER_NAME_2
			frmComputers.txtPrint2SN.Text = comp.PRINTER_SN_2
			frmComputers.txtPrint2Port.Text = comp.PORT_2
			frmComputers.PROizV35.Text = comp.PRINTER_PROIZV_2
		Else
			frmComputers.cmbPrinters2.Visible = False
			frmComputers.txtPrint2SN.Visible = False
			frmComputers.txtPrint2Port.Visible = False
			frmComputers.PROizV35.Visible = False
		End If

		If Not String.IsNullOrEmpty(comp.PRINTER_NAME_3) Then
			frmComputers.sPrinter = 3
			frmComputers.bPrinterPlus.Visible = False
			frmComputers.cmbPrinters3.Visible = True
			frmComputers.txtPrint3SN.Visible = True
			frmComputers.txtPrint3Port.Visible = True
			frmComputers.PROizV36.Visible = True

			frmComputers.cmbPrinters3.Text = comp.PRINTER_NAME_3
			frmComputers.txtPrint3SN.Text = comp.PRINTER_SN_3
			frmComputers.txtPrint3Port.Text = comp.PORT_3
			frmComputers.PROizV36.Text = comp.PRINTER_PROIZV_3
		Else
			frmComputers.cmbPrinters3.Visible = False
			frmComputers.txtPrint3SN.Visible = False
			frmComputers.txtPrint3Port.Visible = False
			frmComputers.PROizV36.Visible = False
		End If

		frmComputers.txtSNAME.Text = comp.NET_NAME
		frmComputers.txtPSEUDONIM.Text = comp.PSEVDONIM

		frmComputers.cmbBranch.Text = comp.FILIAL
		frmComputers.cmbDepartment.Text = comp.MESTO
		frmComputers.cmbOffice.Text = comp.kabn

		sName = comp.NET_NAME

		frmComputers.cmbResponsible.Text = comp.OTvetstvennyj
		frmComputers.txtPHONE.Text = comp.TELEPHONE
		frmComputers.cmbAppointment.Text = comp.TIP_COMPA

		frmComputers.txtSBSN.Text = comp.INV_NO_SYSTEM
		frmComputers.txtMSN.Text = comp.INV_NO_MONITOR
		frmComputers.IN_IBP.Text = comp.INV_NO_IBP
		frmComputers.IN_PRN.Text = comp.INV_NO_PRINTER

		frmComputers.ChkPDC.Visible = comp.TIP_COMPA = "Сервер"

		Dim Gar As Boolean = comp.Garantia_Sist

		If Not Gar Then
			frmComputers.rbKompl.Checked = True
			For Each C In frmComputers.sSTAB1.TabPages(0).Controls
				If TypeOf C Is GroupBox Then C.Cursor = Cursors.Hand
			Next C
			For Each C In frmComputers.sSTAB1.TabPages(1).Controls
				If TypeOf C Is GroupBox Then C.Cursor = Cursors.Hand
			Next C
			For Each C In frmComputers.sSTAB1.TabPages(2).Controls
				If TypeOf C Is GroupBox Then C.Cursor = Cursors.Hand
			Next C
		Else
			frmComputers.rbSist.Checked = True
			For Each C In frmComputers.sSTAB1.TabPages(0).Controls
				If TypeOf C Is GroupBox Then C.Cursor = Cursors.Default
			Next C
			For Each C In frmComputers.sSTAB1.TabPages(1).Controls
				If TypeOf C Is GroupBox Then C.Cursor = Cursors.Default
			Next C
			For Each C In frmComputers.sSTAB1.TabPages(2).Controls
				If TypeOf C Is GroupBox Then C.Cursor = Cursors.Default
			Next C

			Call LOAD_GARs(sID, frmComputers.cmbPostav, frmComputers.dtGPr, frmComputers.dtGok)
		End If

		frmComputers.txtPCSfN.Text = comp.SFAktNo
		frmComputers.txtPCcash.Text = comp.CenaRub
		frmComputers.txtPCSumm.Text = comp.StoimRub
		frmComputers.txtPCZay.Text = comp.Zaiavk

		frmComputers.dtPCdataVvoda.Value = comp.DataVVoda
		frmComputers.dtPCSFdate.Value = comp.dataSF

		frmComputers.chkPCspis.Checked = comp.Spisan
		frmComputers.chkPCNNb.Checked = comp.Balans

		'Получаем номер розетки если он есть
		Dim rs1 As ADODB.Recordset
		rs1 = New ADODB.Recordset
		rs1.Open("SELECT count(*) as t_n FROM TBL_NET_MAG WHERE SVT=" & comp.ID, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		Dim UCount As Integer

		With rs1
			UCount = .Fields("t_n").Value
		End With
		rs1.Close()
		rs1 = Nothing

		If UCount = 0 Then
			frmComputers.Label89.Visible = False
			frmComputers.lblNumberNET.Visible = False
		Else
			frmComputers.Label89.Visible = True
			frmComputers.lblNumberNET.Visible = True

			rs1 = New ADODB.Recordset
			rs1.Open("SELECT id_line FROM TBL_NET_MAG WHERE SVT=" & comp.ID, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs1
				frmComputers.lblNumberNET.Text = .Fields("id_line").Value
			End With
			rs1.Close()
			rs1 = Nothing
		End If

		Dim rs As ADODB.Recordset
		If comp.PCL.HasValue Then
			Dim comp1 As IComp = frmMain.compService.Get(comp.PCL.Value)
			frmComputers.cmbPCLK.Text = comp1.NET_NAME
			comp1 = Nothing
		End If

		'#############################################
		'Проверка есть ли контейнеры в справочнике
		'#############################################

		'Dim sSQL As String = "SELECT count(*) as t_n from spr_other where C='1'"
		'rs = New ADODB.Recordset
		'rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		'Dim A1 As String
		'With rs
		'	A1 = .Fields("t_n").Value
		'End With
		'rs.Close()
		'rs = Nothing

		Dim A1 As Integer = frmMain.otherService.GetAll().Where(Function(o) o.C = "1").Count()

		Select Case A1
			Case 0
				frmComputers.cmbPCLK.Visible = False
				frmComputers.Label88.Visible = False
			Case Else
				frmComputers.cmbPCLK.Visible = True
				frmComputers.Label88.Visible = True

				Call LOAD_PCL(frmComputers.cmbBranch.Text, frmComputers.cmbDepartment.Text, frmComputers.cmbOffice.Text, frmComputers.cmbPCLK)
		End Select

		'#############################################
		'#############################################
		'#############################################

		'Call LOAD_SOFT(sID, frmComputers.lstSoftware)
		'Call LOAD_USER(sID)
		'Call LOAD_NOTES(sID, frmComputers.lvNotes)
		'Call LOAD_REPAIR(sID, frmComputers.lvRepair)
		'Call LOAD_DVIG_TEHN(sID, frmComputers.lvMovement)

		'frmComputers.IN_PRN.Text = frmComputers.IN_PRN.Font.Size & "," & frmComputers.IN_PRN.Font.Style
	End Sub

	Public Sub LOADmon(ByVal sID As String)
		On Error Resume Next

		Dim comp As IComp = frmMain.compService.Get(sID)

		frmComputers.lblsIDOTH.Text = comp.ID

		frmComputers.cmbOTH.Text = comp.MONITOR_NAME
		frmComputers.txtMonDum.Text = comp.MONITOR_DUM
		frmComputers.txtOTHSN.Text = comp.MONITOR_SN
		frmComputers.PROiZV39.Text = comp.MONITOR_PROIZV
		frmComputers.cmbOTHotv.Text = comp.OTvetstvennyj
		frmComputers.txtOTHinnumber.Text = comp.INV_NO_MONITOR
		frmComputers.txtOTHmemo.Text = comp.PORT_1

		frmComputers.cmbOTHFil.Text = comp.FILIAL
		frmComputers.cmbOTHDepart.Text = comp.MESTO
		frmComputers.cmbOTHOffice.Text = comp.kabn

		'sName = .Fields("PRINTER_NAME_1").Value

		'If Not IsDBNull(.Fields("NET_IP_1").Value) Then frmComputers.txtOTHIP.Text = .Fields("NET_IP_1").Value
		'If Not IsDBNull(.Fields("NET_MAC_1").Value) Then frmComputers.txtOTHMAC.Text = .Fields("NET_MAC_1").Value
		'If Not IsDBNull(.Fields("TIP_COMPA").Value) Then frmComputers.cmbOTHConnect.Text = .Fields("TIP_COMPA").Value

		frmComputers.txtOTHphone.Text = comp.TELEPHONE

		frmComputers.txtOTHSfN.Text = comp.SFAktNo
		frmComputers.txtOTHcash.Text = comp.CenaRub
		frmComputers.txtOTHSumm.Text = comp.StoimRub
		frmComputers.txtOTHZay.Text = comp.Zaiavk

		frmComputers.dtOTHdataVvoda.Value = comp.DataVVoda
		frmComputers.dtOTHSFdate.Value = comp.dataSF

		frmComputers.chkOTHspis.Checked = comp.Spisan
		frmComputers.chkOTHNNb.Checked = comp.Balans

		If comp.PCL.HasValue Then
			Dim comp1 As IComp = frmMain.compService.Get(comp.PCL.Value)
			frmComputers.cmbOTHPCL.Text = comp1.NET_NAME
			comp1 = Nothing
		End If

		'Call LOAD_GARs(sID, frmComputers.cmbOTHPostav, frmComputers.dtGOTHPr, frmComputers.dtGOTHok)
		'Call LOAD_NOTES(sID, frmComputers.lvNotesOTH)
		'Call LOAD_REPAIR(sID, frmComputers.lvRepairOTH)
		'Call LOAD_DVIG_TEHN(sID, frmComputers.lvMovementOTH)
	End Sub

	Public Sub LOAD_SOFT(ByVal sID As String, ByVal lstSoftware As ListView)
		On Error Resume Next
		lstSoftware.Items.Clear()

		lstSoftware.Sorting = SortOrder.None
		lstSoftware.ListViewItemSorter = Nothing

		Dim rs As ADODB.Recordset 'Объявляем рекордсет
		Dim sSQL As String 'Переменная, где будет размещён SQL запрос

		sSQL = "SELECT * FROM SOFT_INSTALL WHERE Id_Comp =" & sID & " ORDER BY Soft, NomerSoftKomp"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		Dim intCount As Decimal = 0

		With rs
			.MoveFirst()
			Do While Not .EOF
				lstSoftware.Items.Add(.Fields("id").Value) 'col no. 1

				If Not IsDBNull(.Fields("NomerSoftKomp").Value) Then lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("NomerSoftKomp").Value)

				If Not IsDBNull(.Fields("Soft").Value) Then lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("Soft").Value)

				If Not IsDBNull(.Fields("L_key").Value) Then
					lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("L_key").Value)
				Else
					lstSoftware.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("t_lic").Value) Then
					lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("t_lic").Value)
				Else
					lstSoftware.Items(CInt(intCount)).SubItems.Add("")
				End If
				If Not IsDBNull(.Fields("d_p").Value) Then
					lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("d_p").Value)
				Else
					lstSoftware.Items(CInt(intCount)).SubItems.Add("")
				End If
				If Not IsDBNull(.Fields("d_o").Value) Then
					lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("d_o").Value)
				Else
					lstSoftware.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Publisher").Value) Then
					lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("Publisher").Value)
				Else
					lstSoftware.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("TIP").Value) Then
					lstSoftware.Items(CInt(intCount)).SubItems.Add(.Fields("TIP").Value)
				Else
					lstSoftware.Items(CInt(intCount)).SubItems.Add("")
				End If

				intCount = intCount + 1
				.MoveNext()
			Loop
		End With
		rs.Close()
		rs = Nothing

		ResList(lstSoftware)
	End Sub

	Public Sub LOAD_USER(ByVal sID As String)
		On Error Resume Next
		frmComputers.lstUsers.Items.Clear()

		Dim rs As ADODB.Recordset 'Объявляем рекордсет
		Dim sSQL As String 'Переменная, где будет размещён SQL запрос

		sSQL = "SELECT * FROM USER_COMP WHERE Id_Comp =" & sID & " ORDER BY USERNAME"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		Dim intCount As Decimal = 0

		With rs
			.MoveFirst()
			Do While Not .EOF
				frmComputers.lstUsers.Items.Add(.Fields("id").Value) 'col no. 1

				If Not IsDBNull(.Fields("FIO").Value) Then
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add(.Fields("FIO").Value)
				Else
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("USERNAME").Value) Then
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add(.Fields("USERNAME").Value)
				Else
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("EMAIL").Value) Then
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add(.Fields("EMAIL").Value)
				Else
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("icq").Value) Then
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add(.Fields("icq").Value)
				Else
					frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add("")
				End If

				'If Not IsDBNull(.fields("jabber").value) Then
				'frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add(.fields("jabber").value)
				'Else
				'frmComputers.lstUsers.Items(CInt(intCount)).SubItems.Add("").value
				'End If

				intCount = intCount + 1
				.MoveNext()
			Loop
		End With
		rs.Close()
		rs = Nothing

		ResList(frmComputers.lstUsers)
	End Sub

	Public Sub LOAD_NOTES(ByVal sID As String, ByVal lstGroups As ListView)
		On Error Resume Next
		lstGroups.Items.Clear()

		Dim rs As ADODB.Recordset 'Объявляем рекордсет
		Dim sSQL As String 'Переменная, где будет размещён SQL запрос
		sSQL = "SELECT * FROM Zametki WHERE Id_Comp =" & sID & " ORDER BY date DESC, id DESC"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		Dim intCount As Decimal = 0

		With rs
			.MoveFirst()
			Do While Not .EOF
				lstGroups.Items.Add(.Fields("id").Value) 'col no. 1

				If Not IsDBNull(.Fields("NomerZamKomp").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("NomerZamKomp").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Date").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("Date").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Zametki").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("Zametki").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Master").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("Master").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				intCount = intCount + 1
				.MoveNext()
			Loop
		End With

		rs.Close()
		rs = Nothing
		ResList(lstGroups)
	End Sub

	Public Sub LOAD_REPAIR(ByVal sID As String, ByVal lstGroups As ListView)
		On Error Resume Next
		lstGroups.Items.Clear()

		If frmserviceDesc.ilsCMD.Images.Count = 0 Then
			Call frmservills_load()
		End If

		lstGroups.Sorting = SortOrder.None
		lstGroups.ListViewItemSorter = Nothing

		Dim rs As ADODB.Recordset 'Объявляем рекордсет
		Dim sSQL As String 'Переменная, где будет размещён SQL запрос
		Dim uname As Integer

		rs = New ADODB.Recordset
		sSQL = "SELECT COUNT(*) AS t_number FROM Remont WHERE id_comp=" & sID & " AND PREF='" & frmComputers.sPREF & "'"
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			uname = .Fields("t_number").Value
		End With
		rs.Close()
		rs = Nothing

		ResList(lstGroups)

		If uname = 0 Then Exit Sub

		Dim tID As Long

		'Dim rs As ADODB.Recordset 'Объявляем рекордсет
		'Dim sSQL As String 'Переменная, где будет размещён SQL запрос
		sSQL = "SELECT * FROM Remont WHERE id_comp=" & sID & " and PREF='" & frmComputers.sPREF & "' ORDER BY date DESC, id DESC"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		Dim intCount As Decimal = 0

		'intCount = 0
		'intCount = 0

		lstGroups.SmallImageList = frmserviceDesc.ilsCMD

		'Dim uname As Integer

		With rs
			.MoveFirst()
			Do While Not .EOF
				If .Fields("zakryt").Value = 1 Or .Fields("zakryt").Value = True Then
					uname = 0
				Else
					uname = 1
				End If

				Dim item As ListViewItem = lstGroups.Items.Add(.Fields(0).Value)
				item.ImageIndex = uname

				'lstGroups.Items.Add(.Fields("id").Value) 'col no. 1

				tID = .Fields("id").Value

				If Not IsDBNull(.Fields("NomerRemKomp").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("NomerRemKomp").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Date").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("Date").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("name_of_remont").Value) Then
					If Len(.Fields("name_of_remont").Value) = 0 Then
						lstGroups.Items(CInt(intCount)).SubItems.Add(Left(.Fields("Remont").Value, 35) & "...")
					Else
						's = Right(.Fields("name_of_remont").Value, 50)
						lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("name_of_remont").Value)
					End If
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Uroven").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("Uroven").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("Master").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("Master").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("vip").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("vip").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("srok").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("srok").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				If Not IsDBNull(.Fields("UserName").Value) Then
					lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("UserName").Value)
				Else
					lstGroups.Items(CInt(intCount)).SubItems.Add("")
				End If

				Dim rs1 As ADODB.Recordset 'Объявляем рекордсет
				Dim sSQL1 As String	'Переменная, где будет размещён SQL запрос
				sSQL1 = "SELECT COUNT(*) as t_n FROM remonty_plus WHERE id_rem =" & tID
				rs1 = New ADODB.Recordset
				rs1.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

				With rs1
					If Not IsDBNull(.Fields("t_n").Value) Then
						lstGroups.Items(CInt(intCount)).SubItems.Add(.Fields("t_n").Value)
					Else
						lstGroups.Items(CInt(intCount)).SubItems.Add("0")
					End If
				End With
				rs1.Close()
				rs1 = Nothing

				intCount = intCount + 1
				.MoveNext()
			Loop
		End With
		rs.Close()
		rs = Nothing

		ResList(lstGroups)
	End Sub

	Public Sub LOAD_DVIG_TEHN(ByVal sID As String, ByVal lstGroup As ListView)
		On Error Resume Next
		Dim sNom As Integer
		lstGroup.Items.Clear()

		Dim rscount As ADODB.Recordset 'Объявляем рекордсет
		rscount = New ADODB.Recordset
		rscount.Open("SELECT COUNT(*) AS total_number FROM dvig where id_comp=" & frmComputers.sCOUNT, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rscount
			sNom = .Fields("total_number").Value
		End With
		rscount.Close()
		rscount = Nothing

		ResList(lstGroup)

		If sNom > 0 Then
			Dim rs As ADODB.Recordset 'Объявляем рекордсет
			Dim sSQL As String 'Переменная, где будет размещён SQL запрос

			sSQL = "SELECT ID_comp, data, id, oldmesto, newmesto, prich, time FROM dvig where id_comp=" & frmComputers.sCOUNT
			rs = New ADODB.Recordset
			rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			Dim intCount As Decimal = 0
			With rs
				.MoveFirst()
				Do While Not .EOF
					'NomR = .Fields(0)
					lstGroup.Items.Add(.Fields("id").Value)	'col no. 1

					If Not IsDBNull(.Fields("oldmesto").Value) Then
						lstGroup.Items(CInt(intCount)).SubItems.Add(.Fields("oldmesto").Value)
					Else
						lstGroup.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("newmesto").Value) Then
						lstGroup.Items(CInt(intCount)).SubItems.Add(.Fields("newmesto").Value)
					Else
						lstGroup.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("prich").Value) Then
						lstGroup.Items(CInt(intCount)).SubItems.Add(.Fields("prich").Value)
					Else
						lstGroup.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("data").Value) Then
						lstGroup.Items(CInt(intCount)).SubItems.Add(.Fields("data").Value)
					Else
						lstGroup.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("time").Value) Then
						lstGroup.Items(CInt(intCount)).SubItems.Add(.Fields("time").Value)
					Else
						lstGroup.Items(CInt(intCount)).SubItems.Add("")
					End If

					intCount = intCount + 1

					.MoveNext()
					'DoEvents
				Loop
			End With
			rs.Close()
			rs = Nothing

			ResList(lstGroup)
		End If
	End Sub

	Private Sub LOAD_GARs(ByVal sID As String, ByVal dPost As ComboBox, ByVal dtp As DateTimePicker, ByVal dto As DateTimePicker)
		Dim rsGa As ADODB.Recordset
		Dim A, B, C As String
		Dim dDate As Date
		rsGa = New ADODB.Recordset

		rsGa.Open("SELECT * FROM Garantia_sis WHERE id_Comp=" & sID, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rsGa
			If Not IsDBNull(.Fields("Postav").Value) Then dPost.Text = .Fields("Postav").Value
			If Not IsDBNull(.Fields("Day").Value) Then A = .Fields("Day").Value
			If Not IsDBNull(.Fields("Month").Value) Then B = .Fields("Month").Value
			If Not IsDBNull(.Fields("Year").Value) Then C = .Fields("Year").Value

			dDate = A & "." & B & "." & C
			dtp.Value = dDate

			If Not IsDBNull(.Fields("Day_O").Value) Then A = .Fields("Day_O").Value
			If Not IsDBNull(.Fields("Month_O").Value) Then B = .Fields("Month_O").Value
			If Not IsDBNull(.Fields("Year_O").Value) Then C = .Fields("Year_O").Value

			dDate = A & "." & B & "." & C

			dto.Value = dDate
		End With
		rsGa.Close()
		rsGa = Nothing
	End Sub

	Public Sub LOAD_INF_BRANCHE(ByVal sID As String)
		'Dim sSQL As String
		'On Error GoTo err_
		frmComputers.lvNotesBR.Items.Clear()

		Dim SerD As String
		Dim rs As ADODB.Recordset

		Select Case frmComputers.sPREF
			Case "G"
				SerD = sID & "F"
			Case "O"
				SerD = sID & "O_F"
			Case "K"
				SerD = sID & "K"
		End Select

		Dim sSQL As String
		Dim sCN As String
		Dim sSQL1 As String
		Dim sSQL2 As String
		Dim sSQL3 As String

		sSQL1 = "Select * FROM SES_Pass where id_OF='" & SerD & "'"
		sSQL2 = "Select * FROM OTD_O where Id_OTD='" & SerD & "'"
		sSQL = "Select count(*) as t_n FROM SES_Pass where id_OF='" & SerD & "'"

		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			sCN = .Fields("t_n").Value
		End With
		rs.Close()
		rs = Nothing

		If sCN > 0 Then
			rs = New ADODB.Recordset
			rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs
				frmComputers.txtspplo.Text = .Fields("Ploshad").Value
				frmComputers.txtspvis.Text = .Fields("visota").Value
				frmComputers.txtspPloOneEVM.Text = .Fields("Pl1Pk").Value
				frmComputers.txtspObOneEVM.Text = .Fields("ob1Pk").Value
				frmComputers.cmbSpRemEVM.Text = .Fields("nalpom").Value
				frmComputers.cmbSpVent.Text = .Fields("vent").Value
				frmComputers.cmbSpWater.Text = .Fields("voda").Value
				frmComputers.cmbSpTeplo.Text = .Fields("kanal").Value
				frmComputers.cmbSpKanal.Text = .Fields("teplo").Value
				frmComputers.txtSpWall.Text = .Fields("otdelka").Value
				frmComputers.txtSpMebel.Text = .Fields("mebel").Value
			End With
			rs.Close()
			rs = Nothing
		End If

		sSQL = "Select count(*) as t_n FROM OTD_O where Id_OTD='" & SerD & "'"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			sCN = .Fields("t_n").Value
		End With
		rs.Close()
		rs = Nothing

		If sCN > 0 Then
			rs = New ADODB.Recordset
			rs.Open(sSQL2, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs
				frmComputers.txtBRAddress.Text = .Fields("ADRESS").Value
				frmComputers.txtBRBoss.Text = .Fields("OTV").Value
				frmComputers.txtBRPhone.Text = .Fields("Phone").Value

				If Not IsDBNull(.Fields("Prim").Value) Then
					frmComputers.txtBRMemo.Text = .Fields("Prim").Value
				Else
					frmComputers.txtBRMemo.Text = ""
				End If
			End With
			rs.Close()
			rs = Nothing
		End If

		sSQL = "Select count(*) as t_n FROM ZAM_OTD where ID_OTD='" & SerD & "'"
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			sCN = .Fields("t_n").Value
		End With
		rs.Close()
		rs = Nothing

		If sCN > 0 Then
			sSQL3 = "Select * FROM ZAM_OTD where ID_OTD='" & SerD & "' ORDER BY date DESC, id DESC"

			rs = New ADODB.Recordset
			rs.Open(sSQL3, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			Dim intCount As Decimal = 0

			With rs
				.MoveFirst()
				Do While Not .EOF
					frmComputers.lvNotesBR.Items.Add(.Fields("id").Value) 'col no. 1

					If Not IsDBNull(.Fields("ID_ZAM").Value) Then
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add(.Fields("ID_ZAM").Value)
					Else
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("Date").Value) Then
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add(.Fields("Date").Value)
					Else
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("ZAMETKA").Value) Then
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add(.Fields("ZAMETKA").Value)
					Else
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add("")
					End If

					If Not IsDBNull(.Fields("Master").Value) Then
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add(.Fields("Master").Value)
					Else
						frmComputers.lvNotesBR.Items(CInt(intCount)).SubItems.Add("")
					End If

					intCount = intCount + 1
					.MoveNext()
				Loop
			End With
			rs.Close()
			rs = Nothing
		End If

		ResList(frmComputers.lvNotesBR)

		Exit Sub
err_:
	End Sub

	Public Sub SHED_CHECK()
		Dim rs As ADODB.Recordset

		Dim sSQL, SERT, SERT2 As String
		Dim LNGIniFile As IniFile = frmMain.lang

		sSQL = "SELECT COUNT(*) AS total_number FROM Sheduler"

		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			SERT = .Fields("total_number").Value
		End With
		rs.Close()
		rs = Nothing

		If SERT > 0 Then
			frmMain.lblShed.Visible = True
			'frmMain lblShed
			'LNGIniFile.GetString("frmMain", "lblShed", "")
			frmMain.lblShed.Text = LNGIniFile.GetString("frmMain", "lblShed", "") & " " & "(" & "0" & "/" & SERT$ & ")"

			sSQL = "SELECT COUNT(*) AS total_number FROM Sheduler Where foruser='" & UserNames & "'"

			rs = New ADODB.Recordset
			rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs
				SERT2 = .Fields("total_number").Value
			End With
			rs.Close()
			rs = Nothing

			If SERT2 > 0 Then
				sSQL = "SELECT DATA, FORUSER, OPIS FROM Sheduler Where foruser='" & UserNames & "'"

				rs = New ADODB.Recordset
				rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
				Dim intj As Integer
				intj = 0
				With rs
					.MoveFirst()
					Do While Not .EOF
						If .Fields(0).Value > Date.Today.AddDays(-3) And .Fields(0).Value < Date.Today.AddDays(+3) Then
							If .Fields(1).Value = UserNames Then
								intj = intj + 1

								frmMain.lblShed.Text = LNGIniFile.GetString("frmMain", "lblShed", "") & " " & "(" & intj & "/" & SERT$ & ")"
								frmMain.lblShed.ForeColor = Color.Red
							End If
						End If
						.MoveNext()
						'DoEvents
					Loop
				End With
				rs.Close()
				rs = Nothing
			Else
				frmMain.lblShed.Text = LNGIniFile.GetString("frmMain", "lblShed", "") & " " & "(" & "0" & "/" & SERT$ & ")"
				frmMain.lblShed.ForeColor = Color.Black
			End If
		Else
			frmMain.lblShed.Visible = False
		End If
		'frmMain.lblShed.Text = "Напоминания "
	End Sub

	Public Sub REM_CHECK()
		Dim LNGIniFile As IniFile = frmMain.lang

		On Error Resume Next

		Dim rs As ADODB.Recordset

		Dim sSQL, SERT, SERT2, uname, SERT3 As String

		sSQL = "SELECT COUNT(*) AS total_number FROM Remont"

		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			SERT = .Fields("total_number").Value
		End With
		rs.Close()
		rs = Nothing

		If SERT > 0 Then
			frmMain.lblRem.Visible = True

			rs = New ADODB.Recordset
			rs.Open("SELECT * FROM SPR_Master WHERE A='" & UserNames & "'", DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs
				uname = .Fields("name").Value
			End With
			rs.Close()
			rs = Nothing

			If uname = Nothing Then uname = "ADMINISTRATOR"

			sSQL = "SELECT COUNT(*) AS total_number FROM Remont WHERE otvetstv='" & uname & "'"

			rs = New ADODB.Recordset
			rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

			With rs
				SERT2 = .Fields("total_number").Value
			End With
			rs.Close()
			rs = Nothing
			'LNGIniFile.GetString("frmMain", "lblRem", "") & " " & 
			frmMain.lblRem.Text = LNGIniFile.GetString("frmMain", "lblRem", "") & " " & "(" & "0" & "/" & SERT & ")"

			If SERT2 > 0 Then
				sSQL = "SELECT COUNT(*) AS total_number FROM Remont Where otvetstv='" & uname & "' and zakryt = 0"

				rs = New ADODB.Recordset
				rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

				With rs
					SERT3 = .Fields("total_number").Value
				End With
				rs.Close()
				rs = Nothing

				If SERT3 > 0 Then
					frmMain.lblRem.Text = LNGIniFile.GetString("frmMain", "lblRem", "") & " " & "(" & SERT3 & "/" & SERT & ")"
					frmMain.lblRem.ForeColor = Color.Red
				Else
					frmMain.lblRem.Text = LNGIniFile.GetString("frmMain", "lblRem", "") & " " & "(" & "0" & "/" & SERT & ")"
					frmMain.lblRem.ForeColor = Color.Black
				End If
			Else
				frmMain.lblRem.Text = LNGIniFile.GetString("frmMain", "lblRem", "") & " " & "(" & "0" & "/" & SERT & ")"
			End If
		Else
			frmMain.lblRem.Visible = False
		End If
	End Sub

	Public Sub ExLoadParFow(ByVal sCombo1 As String, ByVal sText1 As TextBox, ByVal sText2 As TextBox, ByVal sCombo2 As ComboBox, ByVal sTABLE As String)
		On Error Resume Next
		Dim rs As ADODB.Recordset
		Dim sSQL As String
		Dim uNI As String
		rs = New ADODB.Recordset

		sSQL = "SELECT * FROM " & sTABLE & " WHERE Name = '" & sCombo1 & "'"

		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			If Not IsDBNull(.Fields("proizv").Value) Then
				uNI = .Fields("proizv").Value
				Dim mfg As IManufacturer = frmMain.mfgService.Get(uNI)

				If Not IsNothing(mfg) Then sCombo2.Text = mfg.Name
			End If

			If Not IsDBNull(.Fields("A").Value) Then sText1.Text = .Fields("A").Value
			If Not IsDBNull(.Fields("B").Value) Then sText2.Text = .Fields("B").Value
		End With
		rs.Close()
		rs = Nothing
	End Sub

	Public Sub ExLoadParTree(ByVal sCombo1 As String, ByVal sText1 As TextBox, ByVal sCombo2 As ComboBox, ByVal sTABLE As String)
		On Error Resume Next

		Dim rs As ADODB.Recordset
		Dim sSQL As String
		Dim uNI As String
		rs = New ADODB.Recordset

		sSQL = "SELECT * FROM " & sTABLE & " WHERE Name = '" & sCombo1 & "'"

		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			If Not IsDBNull(.Fields("proizv").Value) Then
				uNI = .Fields("proizv").Value
				Dim mfg As IManufacturer = frmMain.mfgService.Get(uNI)

				If Not IsNothing(mfg) Then sCombo2.Text = mfg.Name
			End If

			If Not IsDBNull(.Fields("A").Value) Then sText1.Text = .Fields("A").Value
		End With
		rs.Close()
		rs = Nothing
	End Sub

	Public Sub ExLoadParTwo(ByVal sCombo1 As String, ByVal sCombo2 As ComboBox, ByVal sTABLE As String)
		On Error Resume Next

		Dim rs As ADODB.Recordset
		Dim sSQL As String
		Dim uNI As String
		rs = New ADODB.Recordset

		sSQL = "SELECT * FROM " & sTABLE & " WHERE Name = '" & sCombo1 & "'"

		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			If Not IsDBNull(.Fields("proizv").Value) Then
				uNI = .Fields("proizv").Value
				Dim mfg As IManufacturer = frmMain.mfgService.Get(uNI)

				If Not IsNothing(mfg) Then sCombo2.Text = mfg.Name
			End If
		End With
		rs.Close()
		rs = Nothing
	End Sub

	Public Sub REMONT_SEND_MASTER(ByVal sID As String)
		Dim sSQL, sSQL1, a1, b1, c1, d1, e1, g1, h1, i1, j1, k1, l1, PREFs, m1, smtp, frm, srok As String

		sSQL = "SELECT * FROM Remont where id =" & sID

		Dim rs As ADODB.Recordset
		rs = New ADODB.Recordset
		rs.Open(sSQL, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			a1 = .Fields("Date").Value
			b1 = .Fields("Id_Comp").Value
			c1 = .Fields("Remont").Value
			d1 = .Fields("Master").Value
			e1 = .Fields("otvetstv").Value
			g1 = .Fields("name_of_remont").Value
			l1 = .Fields("istochnik").Value
			PREFs = .Fields("PREF").Value

			srok = .Fields("srok").Value
		End With
		rs.Close()
		rs = Nothing

		sSQL1 = "SELECT * FROM SPR_Master where Name ='" & d1 & "'"
		rs = New ADODB.Recordset
		rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			m1 = .Fields("B").Value
			smtp = .Fields("C").Value
		End With
		rs.Close()
		rs = Nothing

		sSQL1 = "SELECT * FROM CONFIGURE"
		rs = New ADODB.Recordset
		rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

		With rs
			frm = .Fields("nr").Value
		End With
		rs.Close()
		rs = Nothing

		If PREFs = "C" Then
			sSQL1 = "SELECT * FROM kompy where id =" & b1
			rs = New ADODB.Recordset
			rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
			With rs
				h1 = .Fields("NET_NAME").Value
				i1 = .Fields("FILIAL").Value
				j1 = .Fields("MESTO").Value
				k1 = .Fields("kabn").Value
			End With
			rs.Close()
			rs = Nothing
		Else
			Select Case PREFs
				Case "G"
					sSQL1 = "SELECT * FROM SPR_FILIAL where id =" & b1
					rs = New ADODB.Recordset
					rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
					With rs
						i1 = .Fields("FILIAL").Value
					End With
					rs.Close()
					rs = Nothing
				Case "O"
					sSQL1 = "SELECT * FROM SPR_OTD_FILIAL where id =" & b1
					rs = New ADODB.Recordset
					rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
					With rs
						i1 = .Fields("FILIAL").Value
						j1 = .Fields("N_Otd").Value
						'k1 = .Fields("MESTO").Value
					End With
					rs.Close()
					rs = Nothing
				Case "K"
					sSQL1 = "SELECT * FROM SPR_KAB where id =" & b1
					rs = New ADODB.Recordset
					rs.Open(sSQL1, DB7, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
					With rs
						i1 = .Fields("N_F").Value
						j1 = .Fields("N_M").Value
						k1 = .Fields("Name").Value
					End With
					rs.Close()
					rs = Nothing
			End Select
		End If

		If Len(m1) = 0 Then
			MsgBox("Отсутствует электронная почта у мастера", MsgBoxStyle.Information, ProGramName)
			Exit Sub
		End If

		If Len(smtp) = 0 Then
			MsgBox("Не указан сервер SMTP", MsgBoxStyle.Information, ProGramName)
			Exit Sub
		End If

		If Len(frm) = 0 Then
			MsgBox("Не заполнен адрес для ответа", MsgBoxStyle.Information, ProGramName)
			Exit Sub
		End If

		If Len(l1) = 0 Then l1 = "Источник не известен. "

		i1 = "Филиал - " & i1 & ", "
		j1 = "Отдел - " & j1 & ", "
		k1 = "Кабинет - " & k1 & ". "
		h1 = "Объект - " & h1 & " "

		Dim Subject As String
		Dim Body As String

		Dim bAns As Boolean = True
		Dim sParams As String

		Dim sTEXT As TextBox
		sTEXT = New TextBox
		sTEXT.Multiline = True
		sTEXT.Text = "Здравствуйте " & d1 & ", " _
 + vbNewLine + "получено сообщение от " & l1 & ": " _
 & vbNewLine & c1 _
 & vbNewLine & "Срок исполнения: " & srok _
 & vbNewLine & h1 _
 & vbNewLine & i1 _
 & vbNewLine & j1 _
 & vbNewLine & k1

		Subject = "БКО::Ремонт " & g1
		sParams = m1

		On Error GoTo err_

		Dim client As New SmtpClient(smtp)
		Dim fromAdr As MailAddress = New MailAddress(frm, ProGramName, System.Text.Encoding.UTF8)
		Dim toAdr As MailAddress = New MailAddress(m1)
		Dim message As MailMessage = New MailMessage(fromAdr, toAdr)
		message.Subject = Subject
		message.SubjectEncoding = System.Text.Encoding.UTF8

		message.Body = sTEXT.Text
		message.BodyEncoding = System.Text.Encoding.UTF8
		'Dim attach As New Attachment("c:\1.txt")
		'message.Attachments.Add(attach)

		client.Send(message)
		message.Dispose()

		sTEXT = Nothing

		MsgBox("Сообщение отправлено", MsgBoxStyle.Information, ProGramName)

		Exit Sub
err_:
		MsgBox(Err.Description)
	End Sub
End Module
